//
//  TripsDetailTableViewCell.m
//  chanyou
//
//  Created by leon on 15/1/2.
//  Copyright (c) 2015年 wanli. All rights reserved.
//

#import "TripsDetailTableViewCell.h"
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)


@implementation TripsDetailTableViewCell

- (void)dealloc
{
    [_descriptionLabel release];
    [_locationButton release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.descriptionLabel = [[UILabel alloc] init];
        _descriptionLabel.numberOfLines = 0;
        _descriptionLabel.font = [UIFont systemFontOfSize:14];
        _descriptionLabel.alpha = 0.85;
        [self.contentView addSubview:_descriptionLabel];
        [_descriptionLabel release];
       
        
        NSDictionary *dic  = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:14.0f], NSFontAttributeName, nil];
        CGRect rect = [self.descriptionLabel.text boundingRectWithSize:CGSizeMake(self.frame.size.width, 10000) options:(NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin) attributes:dic context:nil];
        
        self.locationButton = [[UIButton alloc] initWithFrame:CGRectMake(10, (rect.size.height + SCREEN_WIDTH / 2) + 20, 150, 15)];
        [self.locationButton.titleLabel setTintColor:[UIColor grayColor]];
        [_locationButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _locationButton.titleLabel.font = [UIFont systemFontOfSize:13];
        _locationButton.titleLabel.alpha = 0.5;
        _locationButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        [self.contentView addSubview:_locationButton];
        [_locationButton release];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    NSDictionary *dic  = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:14.0f], NSFontAttributeName, nil];
    CGRect rect = [self.descriptionLabel.text boundingRectWithSize:CGSizeMake(self.frame.size.width, 10000) options:(NSStringDrawingUsesFontLeading|NSStringDrawingUsesLineFragmentOrigin) attributes:dic context:nil];
    [self.descriptionLabel setFrame:CGRectMake(10, 10, self.contentView.frame.size.width - 20, rect.size.height)];
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
